package com.cskaoyan.gateway.controller.shopping;

import com.mall.commons.result.ResponseData;
import com.mall.commons.result.ResponseUtil;
import com.mall.shopping.IContentService;
import com.mall.shopping.constants.ShoppingRetCode;
import com.mall.shopping.dto.NavListResponse;
import com.mall.user.annotation.Anoymous;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @description: 导航栏显示
 * @author wxy
 * @date 2022-01-20 14:02
 * @version 1.0
 */
@RestController
@RequestMapping("/shopping")
public class NavigationController {

    @Reference(timeout = 3000,check = false)
    IContentService contentService;



    @Anoymous
    @RequestMapping("/navigation")
    public ResponseData navigation(){
        NavListResponse navListResponse = contentService.queryNavList();
        if (ShoppingRetCode.SUCCESS.getCode().equals(navListResponse.getCode())){
            //返回一个带数据的响应对象
            return new ResponseUtil().setData(navListResponse.getPannelContentDtos());
        }
        //返回一个错误信息的响应对象
        return new ResponseUtil().setErrorMsg(navListResponse.getMsg());
    }
}
